'use strict';
const db = uniCloud.database();
const dbCmd = db.command
exports.main = async (event, context) => {
	//event为客户端上传的参数
	const {
		username,
		address_Id
	} = event
	const res = await db.collection('uni-id-users').where({
		username: username
	}).update({
		address: dbCmd.pull({
			address_Id: dbCmd.eq(address_Id)
		})
	})

	// const addressList = res.data[0].address
	// const newAddressList = addressList.splice(index, 1)
	// console.log(addressList);
	// const res1 = await db.collection('uni-id-log').where({
	// 	username: username
	// }).update({
	// 	cart: addressList
	// })
	// //返回数据给客户端
	// console.log(res1);
	return res
};
